
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';

/// 通用工具类
class Utility {

  /// 复制到粘贴板上
  static Future<void> copyToClipboard(String text, {bool showSuccessToast=true, String toastMsg="已复制"}){
    return Clipboard.setData(ClipboardData(text: text)).then(
        (value) => {
          if(showSuccessToast){
            // toast
            showToast(toastMsg)
          }
        }
    );
  }

  static void showToast(String tips){
    Fluttertoast.showToast(
        msg: tips,
        toastLength: Toast.LENGTH_SHORT,
        gravity: ToastGravity.BOTTOM,
        timeInSecForIosWeb: 1,
        backgroundColor: const Color(0xfff0f0f0),
        textColor: const Color(0xff4f4f4f),
        fontSize: 14.0
    );
  }

}